package com.dc.refactoring._6_处理概括关系._12_ReplaceDelegationWithInheritance.newObject;

// step 1 声明继承关系
public class Employee extends Person {

    // step 4 去除 受托字段的引用
    //private Person person = new Person();


    // step 2 去除建单的函数调用
    //public String getName(){
    //    return person.getName();
    //}

    //public void setName(String name){
    //    person.setName(name);
    //}

    @Override
    public String toString(){
        // step 3 修改委托函数，使其直接调用超类继承而来的函数
        //return "Emp: " + person.getLastName();
        return "Emp: " + getLastName();
    }


    public static void main(String[] args) {
        Person person = new Employee();
        //Employee employee = (Employee) person;
        new A(person);
    }

    public static class A {
        public A(Person person) {

        }
    }
}
